package club.hicode.daydayup.type;

import club.hicode.daydayup.lambda.Person;
import org.junit.Test;

/**
 * TypeTest
 *
 * @author Liu Chunfu
 * @date 2018-08-07 上午9:45
 **/
public class TypeTest {


    public <T> T createInstance(Class<T> clazz) {
        try {
            return clazz.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }

    public <T> T test1(T t) throws IllegalAccessException, InstantiationException {
        System.out.println(t.getClass());
        return (T) t.getClass().newInstance();
    }


    public <T> void test2(Class<T> tClass) {
        System.out.println(tClass);
    }


    @Test
    public void test() throws InstantiationException, IllegalAccessException {
        Person person = test1(new Person());
        System.out.println("==" + person.getClassName());
    }

    @Test
    public void test2() {
        Person instance = createInstance(Person.class);
        System.out.println(instance.getClass());
    }
}
